package xju_3_4.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class PerformHandler implements InvocationHandler {

    // 目标对象
    private Object target;

    public PerformHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("方法执行之前");
        // 利用反射调用原业务方法
        Object invoke = method.invoke(target, args);
        System.out.println("方法执行完毕");
        return invoke;
    }
}
